import { Component, ViewChild } from '@angular/core';
import { NavParams, Events, AlertController, App, ModalController, NavController, Content, ActionSheetController, LoadingController } from 'ionic-angular';
import { Storage } from '@ionic/storage';
import { Config } from '../../../../providers/config';
import { DomSanitizer } from '@angular/platform-browser';
import { IrpPoolListService } from "./list.service";
import { IrpPoolQueryPage } from "../query/query.component";
import _ from 'lodash';
import * as moment from "moment";

import { Common } from "../../../../providers/common";
import { from } from 'rxjs/observable/from';

@Component({
    selector: 'page-irp-pool-list',
    templateUrl: './list.html',
    providers: [IrpPoolListService]
})
export class IrpPoolListPage {
    moa_page_name: any = "page-irp-scheduler-list";
    moa_page_explain: any = "股票池管理";

    showAllInfo = false;
    listData;
    showitem = [];
    startdate;
    enddate;

    constructor(
        public alertCtrl: AlertController,
        public app: App,
        public modalCtrl: ModalController,
        public navCtrl: NavController,
        public config: Config,
        private sanitizer: DomSanitizer,
        public events: Events,
        public storage: Storage,
        private common: Common,
        private actionSheetCtrl: ActionSheetController,
        private navParams: NavParams,
        public loadingCtrl: LoadingController,
        private listService: IrpPoolListService,
    ) {
        let now = new Date();
        let month = now.getMonth() + 1;
        this.enddate = now.getFullYear() + "-" + (month > 9 ? month : "0" + month) + "-" + (now.getDate() > 9 ? now.getDate() : "0" + now.getDate());
        this.startdate = (now.getFullYear() - 1) + "-" + (month > 9 ? month : "0" + month) + "-" + (now.getDate() > 9 ? now.getDate() : "0" + now.getDate());
        this.loadData();
    }

    loadData() {
        
    }

    advancedQuery() {
        let that = this;
        console.log("打开Modal");
        let queryModal = this.modalCtrl.create(IrpPoolQueryPage, {});

        queryModal.present();
    }

    setShowAllInfo(i) {
        if (this.showitem.indexOf(i) > -1) {
            _.remove(this.showitem, function (n) {
                return n == i;
            });
        } else {
            this.showitem.push(i);
        }
        this.showAllInfo = !this.showAllInfo;
    }

    search() {

    }
}
